<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui" > 

<h:head>
<!-- Contains the Calendar and a set of User options. -->
	<title>CalendarPage</title>
<!-- Style for the schedule --> 
	<style type="text/css">
	.myclass .fc-event,
	.myclass a,
	.myclass .fc-event-inner{
		   background-color: red;
		   border-color: red;
		   color: white;
	}
	</style> 
</h:head> 
<body>
<!-- Dialog windows created by User's choices  -->
<!-- Notification dialog. Shown after User login. Supported by InizializationBean -->
	<p:dialog  header="Notification Checker" widgetVar="notification" position="center" visible="#{inizializationBean.visibility}">
		<!-- User New Invites --> 
		<h:form>
			<h:outputText value="#{inizializationBean.msg}"/>
			<ul>
		    <ui:repeat value="#{inizializationBean.unreadInvites}" var="invite">
		        <li>
		        <h:form>
		        	<h:outputText value="#{invite.event.name}"/>
		        </h:form>
		        </li>
		        <br/>
		    </ui:repeat>
			</ul>
			
		</h:form>
		<h:form>
			<h:outputText value="#{weatherBean.msg}"/>
			<ul>
		    <ui:repeat value="#{weatherBean.unreadNotifications}" var="weatherNot">
		        <li>
		        <h:form>
		        	<h:outputText value="#{weatherNot.event.name}"/><br/>
		        	<h:outputText value="#{weatherNot.event.weather.condition}"/>
		        </h:form>
		        </li>
		        <br/>
		    </ui:repeat>
			</ul>
		</h:form>
		<h:form>
			<p:commandButton value="OK" action="#{inizializationBean.markAsRead()}" onclick="PF('notification').hide()"></p:commandButton>
		</h:form>
	</p:dialog>	
	
<!-- Event creation dialog. Shown after "Add Event". Supported by eventBean -->	
	<p:dialog header="Event Creation" widgetVar="evCreation" position="top" >
		<h:form>
			Date*<br/>
			<p:calendar value="#{eventBean.date}"  pattern="MM/dd/yyyy HH:mm" title="DATE" required="true"/><br/>
			Duration*<br/>
			<p:calendar value="#{eventBean.duration}"  timeOnly="true" pattern="HH:mm" title="DURATION" required="true"/><br/>
			Name*<br/>
			<p:inputText value="#{eventBean.name}" title="NAME" required="true"/><br/>
			Place*<br/>
			<p:inputText value="#{eventBean.place}" title="PLACE" required="true"/><br/>
			
			<p:selectBooleanCheckbox value="#{eventBean.outdoor}" itemLabel="OUTDOOR: is the event outdoor?" required="true" /><br/>
			<p:selectBooleanCheckbox value="#{eventBean.publicVisibility}" itemLabel="VISIBILITY: is this a public event?" required="true"/><br/>
			
			Description*<br/>
			<p:inputTextarea value="#{eventBean.description}" title="DESCRIPTION" required="true"/><br/>
			Invites<br/>
			<p:inputTextarea value="#{eventBean.invites}" title="INVITES: separated by ';'"/><br/>
			Organizers<br/>
			<p:inputTextarea value="#{eventBean.organizers}" title="ORGANIZERS: separated by ';'" /><br/>
			<p:commandButton value="Save" action="#{eventBean.storeEvent}" onclick="PF('evCreation').hide()" oncomplete="PF('myschedule').update()"/>
		</h:form>
	</p:dialog>

<!-- Calendar search dialog. Shown after "Search". It is supported by SearchCalendarBean -->	
	<p:dialog header="Calendar Search" widgetVar="calSearch">
		<h:form>
      	<p:inputText id="searchCal" value="#{searchCalendarBean.calendarToSearch}" />
      	
      	<p:commandButton value="Search" action="#{searchCalendarBean.searchCalendar}"  onclick="PF('calSearch').hide(); PF('calResults').show()" oncomplete="PF('myschedule').update()"/>
      </h:form>
	</p:dialog>	
	
<!-- Calendar results dialog -->
	<p:dialog header="Calendar Results" widgetVar="calResults">
		<h:form>
      		<h:outputText value="If the calendar you are searching is public it will be loaded overwritting your calendar in calendarPage."/><br/>
     		<h:outputText value="The calendar loaded will have red events."/><br/>
     		<h:outputText value="If it is not public you will be automacally redirected to your calendar."/><br/>
     		<p:commandButton value="OK" onclick="PF('calResults').hide()"/>
      </h:form>
	</p:dialog>	

	
<!-- User options from Calendar Page -->
	<h:form>
	
		<p:menubar>
			<p:submenu label="Event Management">
			 	<p:menuitem value="Add events" onclick="PF('evCreation').show()"/>
			 	<p:menuitem value="See events created" action="eventsCreatedPage"/>
 			</p:submenu>
			<p:submenu label="Invite Management">
			 	<p:menuitem value="See invites received" action="invitesReceivedPage"/>
 			</p:submenu>
 			<p:submenu label="Public Calendars">
			 	<p:menuitem value="ReLoad your calendar" action="#{scheduleBean.reload}" oncomplete="PF('myschedule').update()" />
			 	<p:menuitem value="Search calendar " onclick="PF('calSearch').show()"/>
 			</p:submenu>
 			<p:menuitem value="Logout #{userBean.name}" action="#{loginBean.logout()}"/>
		</p:menubar>
      
     </h:form>
      
    <br/>

    
<!-- Shedule: PrimeFaces Component -->
	<p:schedule id="schedule" value="#{scheduleBean.lazyModel}"  widgetVar="myschedule" timeZone="GMT+1" draggable="false" resizable="false">
			
	</p:schedule>

	<h:form>
		<p:selectBooleanCheckbox value="#{inizializationBean.calendarVisibility}" widgetVar="calendarVisibility"/>
		<p:commandButton value="Set Calendar Visibility" action="#{inizializationBean.storeCalendarVisibility()}" oncomplete="PF('calendarVisibility').update()"/>
	</h:form>
	


</body> 
</html>
